YouTube already supports many different formats, so which format to use depends mostly on your own personal preference. Obviously you should, in most cases, aim not change the aspect ratio of your video, and also not to lower the quality below the original source material.
While a given site might not currently support the quality of your video, that does not mean that it will not support it in the future, and uploading high-quality video might be useful in such cases.
Choosing the right format and codecs
For video intended to be uploaded on the Internet, we often want to optimize the filesize, to avoid spending a long time uploading. So try using either the MP4 or avi container formats with the h.264 or h.265 video codecs. Depending on your requirements in regards to quality, you can generally get away with setting a fairly low bitrate with those formats. DIVx and xVID are also good options.
Some video editors may have a template specifically created for "Internet", but if your aim is a low file size, then you likely want to use a custom setting. Some codecs, such as DIVx and xVID, can preserve quality with a relatively low bitrate. For videos that will be uploaded, you often want to save your bandwidth and upload time, so using a different codec than those that came with your video editor can sometimes be a good idea.
For xVID, and source video at around DVD quality, a bitrate between 1k and 3k (in kbps) should suffice, and you should not notice much of a drop in quality, if done right.
It depends on the source however. For HD video, you still want to experiment as of what is acceptable to you. You can try around 7000kbps, and then move your way up if needed – this also depends on codec used. For higher quality HD, try aiming at 10-20k.
Remember that Filesize is = bitrate * running time
If your editor does not allow you to choose a codec yourself, you can just convert your video after rendering it.