Chi-square test is one of the representative nonparametric test. This test verify the correlation between categorical variables.
In order to verify two discrete variables, chi-square tests statistical differences between observation data and expectations.
This test is also statistical hypothesis test whose null hypothesis is that two categorical variables have no relations.
It is quite easy to understand Chi-square test by conducting a test with different samples.
As you can see below, there are two table which has a data of Candidate preference by man and woman. I would like to compare two data. Intuitively, we can guess that there is no difference by man and woman on case-2. However, there is a quite difference preference on case-1.