OPINION OF THE COURT
FLAHERTY, Justice.Appellant, Casualty Reciprocal Exchange, appeals from the order of the Superior Court which affirmed the judgment entered in favor of the American Association of Meat Processors, appellee, on an alleged oral contract obligating appellant to provide rebates to employer members of appellee association who purchased workers’ compensation insurance from appellant. 388 Pa.Super. 179, 565 A.2d 173. The issue is whether the alleged contract is illegal and therefore unenforceable.
*62Appellant, Casualty Reciprocal Exchange (“Casualty” or “the insurer”), is an interinsurance group, headquartered in Missouri, which provides insurance, including workers’ compensation coverage. Appellee, American Association of Meat Processors (“the Association”), is a nationwide trade association with an office in Elizabethtown, Pennsylvania, whose members include small meat processors and other businesses related to the meat processing industry.
In 1967, Casualty solicited the Association to endorse a workers’ compensation insurance program offered by Casualty to members of the Association. The Association endorsed the Casualty program each year from April 1, 1968 to March 31, 1984. During that time, Casualty provided workers’ compensation insurance to those members of the Association who purchased such coverage. The Association also purchased compensation insurance for its own employees through the Casualty program. Beginning April 1, 1984, the Association discontinued its endorsement of Casualty’s program and endorsed a different program.
At the end of each insurance year through March 31, 1983, Casualty paid a rebate to the Association, based on a percentage of the premiums paid to Casualty under the workers’ compensation insurance program endorsed by the Association. The payments were made to the Association under the terms of assignments made by the insured members of the Association, authorizing Casualty to pay the rebates to the Association, which, in turn, passed on the rebates to the insured members on a pro rata basis. When the Association-endorsed program ended on March 31, 1984, Casualty failed to pay a dividend or rebate to the Association for the final year of the program.
The Association brought a civil action in federal court, alleging that the insurer breached an oral agreement to pay the Association, for the insured members, a rebate of at least ten percent of the premiums paid by the participating members. The case was transferred to state court pursuant to 42 Pa.C.S. § 5103. The case was tried without a jury, and the court entered judgment for the Association in *63the amount of $81,195.90, one-tenth of the premiums paid during the final year of the program, together with prejudgment interest. The insurer appealed to the Superior Court, which affirmed the trial court by a divided panel. American Association of Meat Processors v. Casualty Reciprocal Exchange, 388 Pa.Super. 179, 565 A.2d 173 (1989).
We must determine whether the insurer’s alleged oral agreement to return a percentage of the premiums to the Association for transmittal to the insured members violates Pennsylvania law. The insurer claims that such an agreement would violate the Insurance Department Act of 1921, 40 P.S. § 275, as well as other statutory provisions. 40 P.S. § 275 states:
§ 275. Rebates and inducements prohibited
No insurance agent, solicitor, or broker, personally or by any other party, shall offer, promise, allow, give, set off, or pay, directly or indirectly, any rebate of, or part of, the premium payable on the policy or on any policy or agent’s commission thereon, or earnings, profit, dividends, or other benefit founded, arising, accruing or to accrue thereon or therefrom, or any special advantage in date of policy or age of issue, or any paid employment or contract for services of any kind, or any other valuable consideration or inducement, to or for insurance on any risk in this Commonwealth, now or hereafter to be written, which is not specified in the policy contract of insurance; nor shall any such agent, solicitor, or broker, personally or otherwise, offer, promise, give, option, sell, or purchase any stocks, bonds, securities, or property, or any dividends or profits accruing or to accrue thereon, or other thing of value whatsoever, as inducement to insurance or in connection therewith. Nothing in this section shall be construed to prevent the taking of a bona fide obligation, with legal interest, in payment of any premium.
Suitably elided for this case, the statute says: “No insurance agent shall promise or pay, directly or indirectly, any *64rebate of, or part of, the premium payable on the policy for insurance on any risk in this Commonwealth, which is not specified in the policy.” The statute seems to prohibit precisely what Casualty allegedly promised to do in this case.
The Superior Court held that the oral contract did not violate the above statute. Its entire discussion of the issue was:
The Appellee was not an insurance agent, solicitor, or broker in this arrangement, nor was it an insured, within the meaning of the Pennsylvania insurance laws. It was not a party to the insurance policy or contract which existed in each case between one of its members and the Appellant.
388 Pa.Super. at 184, 565 A.2d at 175. The rationale is erroneous on both the facts and the law. In fact, the Association was an insured, and was a party to one of the insurance policies issued by the insurer. Even if that were not the case, the Superior Court has misconstrued the statute, which nowhere requires that a prohibited contract must exist between the insurer and the insured. Instead, the statute prohibits any agreements, between the insurer and anyone else, which promise rebates, direct or indirect, to insured parties, if the rebates are not set forth in the policy.
The Superior Court cited McDowell v. Good Chevrolet-Cadillac, Inc., 397 Pa. 237, 154 A.2d 497 (1959), for the proposition that the statute in question basically prohibits the placement of insurance at a favorable rate regardless of how the favorable rate is obtained, if such a rate is not available to all other members of the same class. This is a correct statement of the law, but it condemns the alleged contract in this case rather than excusing it.
In McDowell, a car dealer was licensed to sell vehicles on an installment basis, and was also licensed as an agent to sell insurance for the vehicles. The dealer arranged financing for the sales so that the buyer was obligated to pay the finance company. The dealer obtained insurance, at stan*65dard rates, for some of the vehicles, naming the finance company and the buyer as insureds. As an insurance agent, the dealer received the usual commissions paid by the insurance company to its agents. The plaintiffs, competing insurance agents, charged that because the dealer received a commission on the sale of the insurance, and because it arguably retained a financial interest in the vehicles, the dealer had obtained insurance at a cost below that paid by other purchasers of insurance, in violation of the statute. This court rejected the plaintiffs’ theory, holding that the dealer did not retain any insurable interest in any vehicles, did not pay for any insurance, and did not receive any insurance.
The relationship among the insurance company, the car dealer, and the insured buyers in McDowell differs greatly from the relationship among Casualty, the Association, and the Association’s insured members in this case. In McDowell, the car dealer received commissions solely for itself and its own benefit; the payments were not passed on to the buyers. Thus, neither the dealer nor the insured buyers received insurance at a reduced rate. In this case, by contrast, the Association received payments only on behalf of its insured members. The Association passed on the payments to the insured members and only to the insured members. If the alleged oral contract is enforced, the insured members of the Association will receive insurance protection at a cost below that available to nonmember businesses which seek workers’ compensation insurance. It is this result, not present in McDowell, which is prohibited by the statute. It is immaterial that the payments are indirect, to be made through the Association serving as a conduit.
The Association presents two arguments to avoid the force of the statute. Preliminarily, it argues that Casualty’s defense of illegality was waived, and secondly, it argues that the statute does not apply because the workers’ compensation insurance provided by Casualty did not insure *66against a “risk in this Commonwealth,” an element of 40 P.S. § 275.
Casualty formally raised the issue of the illegality of the alleged contract under Pennsylvania insurance law for the first time in its post-trial motions. The Association argues that the insurer waived the issue under Pa.R.C.P. 227.1(b), which provides:
(b) Post-trial relief may not be granted unless the grounds therefor,
(1) if then available, were raised in pre-trial proceedings or by motion, objection, point for charge, request for findings of fact or conclusions of law, offer of proof or other appropriate method at trial; and
(2) are specified in the motion. The motion shall state how the grounds were asserted in pre-trial proceedings or at trial. Grounds not specified are deemed waived unless leave is granted upon cause shown to specify additional grounds.
The Association notes that Pa.R.C.P. 1030, New Matter, states: “All affirmative defenses including but not limited to ... illegality ... shall be pleaded in a responsive pleading under the heading ‘New Matter’____” Furthermore, defenses not properly pleaded are waived under Pa.R.C.P. 1032(1), which provides:
A party waives all defenses and objections which he does not present either by preliminary objection, answer or reply, except
(1) that the defense of failure to state a claim upon which relief can be granted, the defense of failure to join an indispensable party, and the objection of failure to state a legal defense to a claim may also be made by a later pleading, if one is permitted, or by motion for judgment on the pleadings or at the trial on the merits ____
Illegality is not one of the exceptions of Rule 1032(1), so the Association argues that the defense was waived by Casualty’s failure to raise the issue during the pleadings.
*67There are two reasons why we reject the Association’s assertion that the issue has been waived. First, although the issue was raised clearly for the first time in post-trial motions, both the trial court and the Superior Court considered the issue on the merits. As set forth following Rule 227.1 in the Explanatory Comment-1983, the purpose of the rule is to give the trial court the opportunity to correct its own error. The fact that the defense was presented to, and ruled upon, by the trial court removes the procedure from the realm condemned in Dilliplaine v. Lehigh Valley Trust Co., 457 Pa. 255, 257, 322 A.2d 114, 116 (1974), where the trial is reduced to a “dress rehearsal” in which the “ill-prepared advocate” hopes that “an appellate court will come to his aid after the fact and afford him relief despite his failure at trial to object,” thus denying the trial court any “chance to hear argument on the issue and an opportunity to correct error.”
What we consider controlling, however, on the question of waiver, is that the alleged contract is illegal under a statute enacted in aid of significant public policies identified by the Pennsylvania legislature. The Pennsylvania Workmen’s Compensation Act is humanitarian and remedial in its purpose, which is to provide workmen and their families a quick and sure means of payment for work-related injuries without resort to litigation. See Wagner v. National Indemnity Co., 492 Pa. 154, 422 A.2d 1061 (1980). The Insurance Department Act of 1921 empowers the Insurance Commissioner to administer and enforce the insurance laws in large part to insure the solvency of insurance companies, which, in the workers’ compensation field, is essential to protect the rights of injured workers. Unauthorized favorable insurance rates, such as those allegedly offered by Casualty in this case, undermine the ability of the Insurance Commissioner to protect the sources of compensation benefits which are indispensable to the welfare of injured workers. In Dippel v. Brunozzi, 365 Pa. 264, 267-68, 74 A.2d 112, 114-15 (1950), this court applied
*68the general rule that an agreement which violates a provision of a statute, or which cannot be performed without violation of such a provision, is illegal and void. Where a contract is found to be against public policy “it cannot, under any circumstances, be made the basis of a cause of action. The law when appealed to will have nothing to do with it, but will leave the parties just in the condition in which it finds them.” ... [Wjhenever it appears that the enforcement of a contract would violate public policy the court should refuse to proceed in an action based solely upon it, and should dismiss the proceedings of its own motion.
(Citations omitted). The illegality of a contract is therefore a question not entirely controlled by the rules of pleading; whenever it appears that the enforcement of a contract would violate public policy, the court should dismiss the proceedings of its own motion. Although the Dippel case predates Rule 227.1, the principle remains viable: the courts of this Commonwealth will not be used to enforce contracts which violate public policy; such contracts are void and the law will have nothing to do with them.
The final argument of the Association is that 40 P.S. § 275 applies only to policies which insure against “any risk in this Commonwealth.” The membership of the Association is nationwide; most of its members who purchased insurance under the Casualty program are employers located in states other than Pennsylvania. The workers’ compensation insurance at issue in this case, the Association therefore argues, insured against the risk of injuries to workers in foreign jurisdictions, not against any risk in this Commonwealth.
We must reject this argument. The Association itself is a Pennsylvania employer and purchased workers’ compensation insurance under the Casualty program. Other Association members who participated in the Casualty program were identified as being Pennsylvania employers. That some, or even most, of the participants are businesses located outside Pennsylvania is immaterial. The alleged *69contract in this case covered risks in this Commonwealth. The interpretation argued by the Association — that the statute applies only if all the risks insured against are in this Commonwealth — would totally emasculate the insurance law and the power of the Insurance Commissioner to enforce that law. Every standard automobile insurance policy issued in Pennsylvania insures against risks outside the Commonwealth, as coverage does not cease when the automobile crosses the border into a contiguous state, yet such automobile policies indisputably must comply with Pennsylvania insurance laws and regulations. The Association’s theory would exempt all of these policies from the statute because some of the risks are not “in the Commonwealth.”
This is absurd. Like an automobile policy, a workers’ compensation insurance policy covers risks both within and outside the state where the employer is located. See 77 P.S. §§ 1, 411.2. If every risk covered by a policy had to be in Pennsylvania, then no insurance policy would be governed by the prohibition in the statute, and the statute would be rendered a nullity. The legislature did not intend such a result. 1 Pa.C.S. § 1922(1) and (2).
The alleged agreement between Casualty and the Association encompassed risks within the Commonwealth; it was allegedly made within the Commonwealth; one of the parties to the alleged agreement was a Pennsylvania employer; the alleged agreement violates the public policy of the Commonwealth. Such an agreement is void ab initio and unenforceable. The cause of action stated by the Association does not, therefore, entitle it to relief, and the judgment of the Superior Court must be reversed.
Judgment reversed.
NIX, C.J., and CAPPY, J., did not participate in the consideration or decision of this case. ZAPPALA, J., concurs in the result. LARSEN, J., files a dissenting opinion.