As with most questions in U.S. law, the answer to "Which law governs this?" is "Which state are you in?" I'm in the state of Connecticut, so here's the text of the law that necessitates that disclaimer for products sold in my state:
Sec. 42-296. Sweepstakes. Restrictions on advertisements. No person may advertise a sweepstakes if there is any condition or restriction attached to the receipt of any prize a person wins in the sweepstakes, unless the condition or restriction to claim the prize is through any method which does not require any purchase, payment of a fee or any other consideration, such as (1) a telephone call in the participant’s extended local calling area, (2) a telephone call to an 800 number, or (3) a visit to a retail establishment in the local marketing area which does not require the participant to attend a sales presentation.
Most states presumably have similar laws. Note that this law is technically not part of the "gambling laws" of Connecticut: it's part of Title 42, which covers "Business, Selling, Trading, and Collection Practices". However, the "no purchase necessary" disclaimer is also referenced in Title 53, "Crimes", in the chapters referring to prohibited gambling activities (italics mine):
Sec. 53-278g. Gambling: Excepted activities. (a) Nothing in sections 53-278a to 53-278g, inclusive, shall be construed to prohibit the publication of an advertisement of, or the operation of, or participation in ... a promotional drawing for a prize or prizes, conducted for advertising purposes by any person, firm or corporation other than a retail grocer or retail grocery chain, wherein members of the general public may participate without making any purchase or otherwise paying or risking credit, money, or any other tangible thing of value or a sweepstakes conducted pursuant to sections 42-295 to 42-301, inclusive.
This raises the question of why grocers can't run sweepstakes in Connecticut. I really have no clue there.
From the Dept. of You Didn't Ask But I'm Telling You Anyways: If you run into a sweepstakes that requires a "skill-testing question", you're probably in Canada instead of in the US. (Or you've encountered a sweepstakes that runs throughout North America.) Canadian federal law, specifically the Competition Act, bars companies from engaging in any activity in which prizes are awarded on the basis of chance alone:
74.06 A person engages in reviewable conduct who, for the purpose of promoting, directly or indirectly, the supply or use of a product, or for the purpose of promoting, directly or indirectly, any business interest, conducts any contest, lottery, game of chance or skill, or mixed chance and skill, or otherwise disposes of any product or other benefit by any mode of chance, skill or mixed chance and skill whatever, where
(c) selection of participants or distribution of prizes is not made on the basis of skill or on a random basis in any area to which prizes have been allocated.
Thus, Canadian residents who win a sweepstakes are usually asked to answer a "skill-testing question", which is usually a relative straightforward math problem such as "What is (7 x 9) + 12 - 30?"