If is a subordinator similar to whether, marking the subordinate clause as interrogative (e.g., I don't know if that works).
As a subordinator, if has no conditional meaning (for that, see if (preposition)). Instead, it introduces subordinate closed interrogative clauses.[1]: 972–973 This aligns if with whether, and the two may often be used interchangeably, as in I doubt whether/if that's true. However, if is more constrained. As examples, it can appear neither in the whether or not construction (whether/*if or not the room is ready[a]), nor for a clausal subject (Whether/*If to attend was the question).
Traditional grammar books commonly treat if, often understood as a single word encompassing both this subordinator and the homonymous preposition, as a "subordinating conjunction", a category covering a broad range of clause-connecting words.[1]: 599–600, 738, 1011–1014
History
The Oxford English Dictionary traces the word back to its Germanic roots, with cognates in several old Germanic languages, each broadly carrying the meaning of 'if' or 'whether'. The subordinator if (along with the conditional preposition if) existed in the earliest records of English. Examples of the subordinator follow:
Ðonne
Then
mæg
may
mon
one
geseon
see
gif
if
ðær
there
hwelc
any
dieglu
secret
scond
shame
inne
in
bið.
is
Ðonne mæg mon geseon gif ðær hwelc dieglu scond inne bið.
He.. frægn gif him wære æfter neodlaðu[m] niht getæse.
He asked if him was after urgent-journey night agreeable
'He asked if the night had passed to his liking after the urgent journey.' Beowulf 1319 (Old English, from between 975 and 1025)[3]
The OED notes the existence of forms with an initial g, reflecting a palatal /j/.[4]
Notes
^This article uses asterisks⟨*⟩ to indicate ungrammatical expressions. Thus Whether/*if or not the room is ready should be understood as "Whether or not the room is ready is grammatical, but if or not the room is ready is ungrammatical".