Is it illegal for a state legislature to make it harder for groups
that predominantly support one political party to vote to hurt that
party electorally? If so have any states ever been punished for this?
Sort of, but not precisely. The protection of the many particular groups is stronger than the protection of the political parties per se.
The Voting Rights Act of 1965 previously required states which had a history of discrimination to obtain pre-qualification from the federal government for changes in election administration practices or laws. But, the U.S. Supreme Court in the case of Shelby County v. Holder (2013), invalidated that provision of the Voting Rights Act, giving states much more latitude in practice to enact restrictions.
The closest thing to a case on point is the U.S. Supreme Court case of Romer v. Evans, 517 U.S. 620 (1996).
It's narrow holding was that a Colorado requirement that local government provisions protecting gay rights were subject to greater legislative limitations than other municipal legislation unconstitutionally violated the 14th Amendment's equal protection clause. The official syllabus of the case explains that:
After various Colorado municipalities passed ordinances banning
discrimination based on sexual orientation in housing, employment,
education, public accommodations, health and welfare services, and
other transactions and activities, Colorado voters adopted by
statewide referendum "Amendment 2" to the State Constitution, which
precludes all legislative, executive, or judicial action at any level
of state or local government designed to protect the status of persons
based on their "homosexual, lesbian or bisexual orientation, conduct,
practices or relationships." Respondents, who include aggrieved
homosexuals and municipalities, commenced this litigation in state
court against petitioner state parties to declare Amendment 2 invalid
and enjoin its enforcement. The trial court's grant of a preliminary
injunction was sustained by the Colorado Supreme Court, which held
that Amendment 2 was subject to strict scrutiny under the Equal
Protection Clause of the Fourteenth Amendment because it infringed the
fundamental right of gays and lesbians to participate in the political
process. On remand, the trial court found that the amendment failed to
satisfy strict scrutiny. It enjoined Amendment 2's enforcement, and
the State Supreme Court affirmed.
Held: Amendment 2 violates the Equal Protection Clause. P
(a) The State's principal argument that Amendment 2 puts gays and
lesbians in the same position as all other persons by denying them
special rights is rejected as implausible. The extent of the change in
legal status effected by this law is evident from the authoritative
construction of Colorado's Supreme Court-which establishes that the
amendment's immediate effect is to repeal all existing statutes,
regulations, ordinances, and policies of state and local entities
barring discrimination based on sexual orientation, and that its
ultimate effect is to prohibit any governmental entity from adopting
similar, or more protective, measures in the future absent state
constitutional amendment-and from a review of the terms, structure,
and operation of the ordinances that would be repealed and prohibited
by Amendment 2. Even if, as the State contends, homosexuals can find
protection in laws and policies of general application, Amendment 2
goes well beyond merely depriving them of special rights. It imposes a
broad disability upon those persons alone, forbidding them, but no
others, to seek specific legal protection from injuries caused by discrimination in a wide range of public and
private transactions.
(b) In order to reconcile the Fourteenth Amendment's promise that no
person shall be denied equal protection with the practical reality
that most legislation classifies for one purpose or another, the Court
has stated that it will uphold a law that neither burdens a
fundamental right nor targets a suspect class so long as the
legislative classification bears a rational relation to some
independent and legitimate legislative end. See, e. g., Heller v. Doe,
509 U. S. 312, 319-320. Amendment 2 fails, indeed defies, even this
conventional inquiry. First, the amendment is at once too narrow and
too broad, identifying persons by a single trait and then denying them
the possibility of protection across the board. This disqualification
of a class of persons from the right to obtain specific protection
from the law is unprecedented and is itself a denial of equal
protection in the most literal sense. Second, the sheer breadth of
Amendment 2, which makes a general announcement that gays and lesbians
shall not have any particular protections from the law, is so far
removed from the reasons offered for it, i. e., respect for other
citizens' freedom of association, particularly landlords or employers
who have personal or religious objections to homosexuality, and the
State's interest in conserving resources to fight discrimination
against other groups, that the amendment cannot be explained by
reference to those reasons; the amendment raises the inevitable
inference that it is born of animosity toward the class that it
affects. Amendment 2 cannot be said to be directed to an identifiable
legitimate purpose or discrete objective. It is a status-based
classification of persons undertaken for its own sake, something the
Equal Protection Clause does not permit.
Unlike sexual orientation, political party membership is not itself a "protected classification." Indeed, in 2019, the U.S. Supreme Court specifically held that intentional partisan gerrymandering, per se, was not unconstitutional, in the case of Rucho v. Common Cause. The official syllabus of that case sums up the Court's conclusion as follows:
The conclusion that partisan gerrymandering claims are not justiciable
neither condones excessive partisan gerrymandering nor condemns
complaints about districting to echo into a void. Numerous States are
actively addressing the issue through state constitutional amendments
and legislation placing power to draw electoral districts in the hands
of independent commissions, mandating particular districting criteria
for their mapmakers, or prohibiting drawing district lines for
partisan advantage. The Framers also gave Congress the power to do
something about partisan gerrymandering in the Elections Clause. That
avenue for reform established by the Framers, and used by Congress in
the past, remains open.
On the other hand, the U.S. courts have held that the constitution places limits (in part, under the First Amendment Freedom of Association and under the 14th Amendment) upon what limitations can be placed on third-party ballot access.
The Supreme Court has not expressly ruled on the maximum level of
restrictions that can be imposed on an otherwise qualified candidate
or political party seeking ballot access. As a result, lower courts
have often reached difficult conclusions about whether a particular
ballot access rule is unconstitutional.
Requiring an otherwise eligible candidate or political party to obtain
signatures greater than 5% of the eligible voters in the previous
election may be unconstitutional. This is based on Jenness v.
Fortson, 403 U.S. 431 (1971); the court upheld a restrictive ballot
access law with this 5% signature requirement, whereas the Williams
v. Rhodes (1969) had involved a 15% signature requirement. Most State
ballot access requirements, even the more restrictive ones, are less
than 5%, and the Supreme Court has generally refused to hear ballot
access cases that involved an Independent or minor party candidate
challenging a ballot access law that requires less than 5%.
The implication of the ballot access cases is that some election laws which specifically (and really intentionally as well) disadvantage particular political parties, as opposed to merely having the effect of favoring one party over another in connection with neutral election administration laws may be unconstitutional.
Also, while partisan discrimination in election administration and election laws is not allowed, racial discrimination in election administration and election laws (including racial gerrymandering) is prohibited by both the constitution and statutory provisions such as the Voter Rights Act. So, since there is a strong correlation between race and partisan affiliation, laws which have the effect of trying to favor one political party over another, often constitute illegal racial inequalities in election administration and election law. As Wikipedia explains in its entry on the racial gerrymandering U.S. Supreme Court case Miller v. Johnson, 515 U.S. 900 (1995):
Question before the Supreme Court
Is racial gerrymandering of the congressional redistricting process a
violation of the Equal Protection Clause?
Decision of the Court
Justice Kennedy wrote the majority opinion for the Court. Ruling
against the district, the Court declared the district unconstitutional
under the Equal Protection Clause of the Fourteenth Amendment,
according to the interpretation in Shaw v. Reno (1993). The court
noted that in some instances, "a reapportionment plan may be so highly
irregular and bizarre in shape that it rationally cannot be understood
as anything other than an effort to segregate voters based on race."
Citing Shaw v. Reno, the majority concluded that strict scrutiny is
required whenever race is the "overriding, predominant force" in the
redistricting process.
The U.S. Constitution (as amended) does not contain an affirmative right to vote (which is established by state law), but does bar the right to vote from being burdened or abridged on the basis of race, previous condition of servitude, sex, age over eighteen, or non-payment of a poll tax. Many partisan voting disabilities would also violate these limitations.
There are also federal statutory protections for voters in military service and disabled voters, and the 14th Amendment together with Article I of the U.S. Constitution and statutory law, also prohibits discrimination against naturalized citizens relative to natural born citizens in all respects except qualifications to run as President of the United States.