How should I encode my music for preserving the sound quality and be able to play it on iTunes and iOS?
You can use X Lossless Decoder(XLD) too:


  X Lossless Decoder(XLD) is a tool for
  Mac OS X that is able to
  decode/convert/play various 'lossless'
  audio files. The supported audio files
  can be split into some tracks with cue
  sheet when decoding. It works on Mac
  OS X 10.4 and later.


because it's lossless it keeps the best sound quality. 

Apple recommends using the following formats for your iTunes:


Audio files (AAC, MP3) with appropriate file extensions (.m4a, .mp3). For best results during playback, Apple recommends converting MP3 files greater than 32 megabytes (MB) to AAC format. For AAC audio files, Apple recommends the following specifications:
Audio Format: Baseline Low-Complexity Profile with AAC-LC (Music)
Data Rate: Up to 160 Kbps
Channels: Stereo in .m4v, .mp4, and .mov formats
Output Sample Rate: 48 kHz
Encoding Quality: Better