It is totally optional - yes.
Would I do it if the room was not cleaned well? No.
But I have walked by some rooms & seen the mess that has been left in there. Some people are totally & completely disgusting - just because we are nice normal people on here, trust me, a lot of the traveling community is NOT. I'm not sure I could do the job for any amount of money. I tried to get my DD to get a hotel housekeeping job when she turned 16 so that she would actually APPRECIATE other jobs she had in the future.
Yes, I waitress on weekends. Base wage is $2.13 per hour. So the housekeeper may start at $11 an hour & make a bigger base wage than I do? Don't care, I'll still tip. She won't turn over as many rooms as I can turn over customers in a shift, so the amount of tips she gets assuming 50% leave one will not be monumental.
I never have had envelopes pre-made for any trip (will this time), but normally there is a notepad on the table (in most hotels), so I will write 'Thank you' on a slip & leave it on the pillow with the tip.
Totally optional - do NOT feel guilty if you decide not to do it. I just know it gives me a good feeling myself when someone is doing something for me that I hate to do myself. I just consider it part of my budget, just as when I determine if I will park on-site or off at the airport, do a rental car or taxi (Vegas) or ME (Disney), do table service or counter, etc. It's all part of the equation for me.