Most items have a set number -- before the Scout update introduced the Sandman, no item went higher than level 10.
About the time of the Spy / Sniper update, there was a glitch in the random drop system, and normal weapons (that usually have a fixed level number) were generated with a random level between one and one hundred. This has since been fixed, so if you see, to use one of my own items for example, a level 56 Dead Ringer, that means the item is very old. (And now with the latest patch, you'll never see a non-vintage oddly leveled item)
On the other hand, hats will always have a random level. This means nothing, but certain levels are certainly more valuable for trading, for pure sentimental value. (1, 100, 69, 42, etc.)
The singular exception to all of the above is the new Dueling Badge medal misc item, which actually "levels up" as you kill folks during your duels. A level 100 dueling badge works out to 1000 kills (Might be off a factor of ten) during duels, and likewise the rarity of the badge itself (bronze, silver, gold, platinum) is based on level increment. 0-25,26-50,51-75,76-99,100, etc.
In no case does the level of an item have any effect on gameplay.
Paint will not necessarily increase the value of a hat for a potential buyer, and very well may make it much harder to sell said painted hat. Certain colors are more desired than others, mostly the ones that cannot be found through random drops, e.g. black, white, team colors, after eight, mann's mint, pink as hell, and lime.
In general, you would likely get more value selling the paint separately, and it would be much easier to sell than finding someone who wants both the hat and the color together.
Best Answer
Qualities (Genuine, Unusual, Strange, etc.) are independent of modifications made by tools such as paint and name tags and cannot ever be changed. (Unless you count the Strange Bacon Grease, which probably takes away the original item and gives a strange one.)
If you rename an item, the name will still be displayed in the color for its quality, but the quality will not be added to the name you choose. For example, if you rename your “Genuine Ham Shank” to “Squishy Club”, its name will not be “Genuine Squishy Club”, but just “Squishy Club” (in green text).
Notably, renamed Strange items do not change their name as they rank up (the rank is instead displayed as a subtitle under the name).
For an example, here's my renamed Vintage Flare Gun in TF2's backpack view (with quality colors turned on):