The words firm (referring to a business partnership) and farm are related; they both ultimately come from the Latin firmus, meaning firm or stable. This led to the verb firmāre, meaning to make firm or to affirm and thus to sign. Firm was borrowed from Italian or German in the 18th century. I'm not sure if firm came to refer to businesses because they were based on legal documents requiring signatures or because the name of the business was considered the signature.
Farm was borrowed four centuries earlier from the French form ferme. (Some historical sound changes in English changed /ɛr/ to /ar/ in some cases, creating variations like clerk/clark and person/parson and wacky spellings like sergeant and heart.) It originally meant a fixed payment in rent or taxes and then a piece of land rented out. By the 1500s it had come to mean a piece of land rented out for cultivation. Eventually it lost the sense of being leased and came to refer any land used for cultivation.