The chi-square test is used to test for independence and goodness of fit between categorical variables. It compares observed frequencies to expected frequencies if no association exists. In this example, a chi-square test is performed on data from an influenza vaccine trial to determine if the difference in influenza rates between the vaccine and placebo groups could be due to chance. The test statistic is calculated and compared to the critical value, showing a statistically significant difference and confirming vaccine effectiveness.