Cricket has been played in England as far back as the 1500s, but it was in the 1700s that it became established as a sport with its own rules and etiquette, much of which depends on the honesty of individual players even if means their team lose a wicket. “It’s just not cricket” is therefore a way of criticising someone for some sort of bad behaviour out of line with the rules of polite society.
Another phrase of cricketing origin is to “play a straight bat”, meaning to speak or behave in a simple, correct manner without elaboration. The straight bat was introduced into the game as a response to the innovation of over-arm bowling in the late 1700s, bats having previously been more like hockey sticks. Playing a ‘straight bat’ is to plant your bat vertically and just defend.
Despite its later reputation as a courteous game, cricket suffered the usual attempts at cheating, including making bats the width of the stumps (imagine that!) until Hambledon Cricket Club in Hampshire laid down a set of rules in the mid-1700s. Marylebone Cricket Club in London then took over administration of the rules in 1788 and has been their custodian ever since.